package indi.h.filefilter.callables;

import java.util.concurrent.Callable;

import indi.h.filefilter.filters.Filter;
import indi.h.filefilter.filters.Filter.FilterR;
import indi.h.filefilter.interceptors.Interceptor;
import indi.h.filefilter.listeners.InterceptorListener;

public class InterceptorCallable implements Callable<Filter.FilterR> {
	private Interceptor inter;
	private InterceptorListener il;

	public InterceptorCallable(Interceptor inter) {
		this.inter = inter;
	}

	public InterceptorCallable(Interceptor inter, InterceptorListener il) {
		this.inter = inter;
		this.il = il;
	}

	@Override
	public FilterR call() throws Exception {
		// TODO Auto-generated method stub
		if (this.il != null) {
			this.il.interceptEnd(this.inter.intercept());
			return null;
		} else
			return this.inter.intercept();
	}

}
